<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:set var="b" value="${board}"/>

		<style type="text/css">
			.contents { width: 550px; height: 250px;
				display: inline-block; 
				border: 1px solid gold;
				overflow: auto; }
			.dragup { vertical-align: top; }	
		</style>

		<div id="content">
			<h2>게시판 본문</h2>
			<div id="view">
				<div><label>제목</label><span>${b.title}</span></div>
				<div><label>작성자</label><span>${b.uid}</span></div>
				<div><label>작성일</label><span>${b.wdate}</span></div>
				<div><label>조회수</label><span>${b.reades}</span></div>
				<div><label class="dragup">본문</label>
				<span class="contents">	${b.contents}</span></div>
				<c:if test="${not empty sessionScope.uid and sessionScope.uid eq b.uid }">
				<div><label> </label><button type="button" id="updbtn">수정하기</button>
					<button type="button" id="delbtn">삭제하기</button> </div>
				</c:if>
				<c:if test="${empty sessionScope.uid or sessionScope.uid ne b.uid }">
					<h3 style="color:red">로그인 하세요!</h3>
				</c:if>
			</div>
		</div><!-- // content -->
		
		<script type="text/javascript">
		try{
			var deletebtn = document.getElementById("delbtn");
			deletebtn.onclick = function () { 
				if ( confirm('정말로 삭제하시겠습니까?') ) {
					location.href="?action=deleteok&bdno=${b.bdno}";                            
				}
			};
			var updatebtn = document.getElementById("updbtn");
			updatebtn.onclick = function() {
				location.href="?action=update&bdno=${b.bdno}" ;
			};
		}catch(e){
			
		}	
			//본문 줄바꿈 처리
			var c =document.getElementsByClassName("contents");
			//alert(c[0].innerHTML);
			c[0].innerHTML=c[0].innerHTML.replace(new RegExp('\r?\n','g'),"<br/>");
			// '\r?\n','g' <-- g 는 한번만 찾아 실해 하는게 아니고 지정한 문자열 전체에서 찾는것이다
			
		</script>
		

